import 'package:baselib/net/dioutils.dart';
import 'package:dio/dio.dart';
import 'package:framelib/net/request_manager.dart';
import 'package:baselib/net/baseentity.dart';
import 'package:moduleone/entity/module_one_entity_factory.dart';
class ModuleOneNetUtils{

  //切换设置公共headers
  static List<Map<String,dynamic>> _setCommHeaders(){
    // DioUtils.instance.setHeaders(headers: headers);
    return [{'name':'li'}];
  }
  //设置
  /**
   * post请求
   */
  static postData<T>(String url,
      {
        String baseUrl, dynamic params, CancelToken cancelToken, Options options,
      }) async{
    BaseEntity requestGetData =await RequestManager.postData(url,baseUrl: baseUrl,params: params,cancelToken: cancelToken,options: options);
    requestGetData.data=ModuleOneEntityFactory.generateOBJ<T>(requestGetData.data);
    return requestGetData;
  }
  /**
   * get请求
   */
  static getData<T>(String url,
      {
        String baseUrl, Map<String,dynamic> params, Map<String, dynamic> queryParameters, CancelToken cancelToken, Options options}) async{
    BaseEntity requestGetData =await RequestManager.getData(url,baseUrl: baseUrl,params: params,cancelToken: cancelToken,options: options);
    requestGetData.data=ModuleOneEntityFactory.generateOBJ<T>(requestGetData.data);
    return requestGetData;
  }

  /**
   * put请求
   */
  static putData<T>(String url,
      {
        String baseUrl, Map<String,dynamic> params, CancelToken cancelToken, Options options,
      }) async{

    BaseEntity requestGetData =await RequestManager.putData(url,baseUrl: baseUrl,params: params,cancelToken: cancelToken,options: options);
    requestGetData.data=ModuleOneEntityFactory.generateOBJ<T>(requestGetData.data);
    return requestGetData;
  }

  /**
   * delete请求
   */
  static deleteData<T>(String url,
      {
        String baseUrl, Map<String,dynamic> params, CancelToken cancelToken, Options options,
      }) async{

    BaseEntity requestGetData =await RequestManager.deleteData(url,baseUrl: baseUrl,params: params,cancelToken: cancelToken,options: options);
    requestGetData.data=ModuleOneEntityFactory.generateOBJ<T>(requestGetData.data);
    return requestGetData;
  }
}